package com.lanmaoly.cunzheng.weather;

import java.util.ArrayList;
import java.util.List;

/**
 * 天气
 *
 * @author
 */
public class WeatherData implements Subject {

    private final List<Observer> observers;
    private float a;
    private float b;
    private float c;

    public WeatherData() {
        observers = new ArrayList<>();
    }

    @Override
    public void registObserver(Observer observer) {
        observers.add(observer);
    }

    @Override
    public void delObserver(Observer observer) {
        if (observers.indexOf(observer) >= 0) {
            observers.remove(observer);
        }
    }

    @Override
    public void notifyObservers() {
        observers.stream().forEach(observer -> {
            observer.update(a, b, c);
        });
    }

    public void changed() {
        notifyObservers();
    }

    public void setMensurements(float a, float b, float c) {
        this.a = a;
        this.b = b;
        this.c = c;
        changed();
    }

    public float getA() {
        return a;
    }

    public void setA(float a) {
        this.a = a;
    }

    public float getB() {
        return b;
    }

    public void setB(float b) {
        this.b = b;
    }

    public float getC() {
        return c;
    }

    public void setC(float c) {
        this.c = c;
    }
}
